/**
 * 对一组节点的active属性进行控制
 */
cc.Class({
    extends: cc.Component,

    properties: {
        nodes: {
            default: [],
            type: [cc.Node]
        },
        activateSoloOnStart: {
            default: -1,
            type: cc.Integer,
            tooltip: '开始时要显示的节点的索引，-1为什么都不干'
        }
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start() {
        if (this.activateSoloOnStart >= 0)
            this.activateSolo(this.activateSoloOnStart);
    },
    /**
     * 只激活指定index的node
     * @param {*} index 
     */
    activateSolo(eventOrIndex, indexOrNull) {
        // 兼容属性检查器的使用
        var index = eventOrIndex;
        if (eventOrIndex instanceof cc.Event || eventOrIndex instanceof cc.Component)
            index = indexOrNull;
        //
        for (var i = 0; i < this.nodes.length; ++i) {
            var node = this.nodes[i];
            if (i == index) {
                node.active = true;
            } else {
                node.active = false;
            }
        }
    },


    // update (dt) {},
});
